package com.service.ljl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.dao.ljl.billrecorddao;
import com.dao.ljl.payrecorddao;
import com.entity.Billrecord;
import com.entity.Payrecord;

@Service
@Transactional(rollbackFor = ServiceException.class)
public class billrecordservice {
	@Autowired
	private billrecorddao billrecorddao;
	@Autowired
	private payrecorddao payrecorddao;

	public void add(Map map) {
		Billrecord billrecord = JSONObject.parseObject(map.get("billrecord").toString(), Billrecord.class);
		Long id = JSONObject.parseObject(map.get("id").toString(), Long.class);
		billrecord.setPayrecord(payrecorddao.findOne(id));
		billrecorddao.save(billrecord);

	}

	public void delete(Long id) {
		billrecorddao.delete(id);
	}

	public void deletes(List<Long> ids) {
		for (int i = 0; i < ids.size(); i++) {
			billrecorddao.delete(ids.get(i));
		}
	}

}
